package hotel.switchs.oversea.biz.controller;

import hotel.base.oversea.utils.Result;
import hotel.switchs.oversea.api.VO.GetRoonPriceReturnVo;
import hotel.switchs.oversea.api.VO.request.BatchPushRoomVo;
import hotel.switchs.oversea.api.VO.request.GetPushRoomDataLogVo;
import hotel.switchs.oversea.api.VO.request.GetRoomPriceVo;
import hotel.switchs.oversea.api.VO.request.GetRoomRateChangeVo;
import hotel.switchs.oversea.biz.service.SwitchRoomPriceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author lmf
 * @Date 2020/6/2 15:04
 *  房价 相关控制器
 **/
@RestController
@Slf4j
@Api(value = "SwitchRoomPriceController",tags = {"房价相关控制器"})
@RequestMapping("/switchRoomPrice")
public class SwitchRoomPriceController {

    @Autowired
    private SwitchRoomPriceService switchRoomPriceService;

    /**
     * 直连推送报价等数据接口
     * 注意:新建的房型请延迟6分钟以上推送数据，
     * 否则数据可能会有问题（系统有缓存，会有一定延迟导致）。
     * 接口有重复性检验，开始日期+结束日期+渠道+具体的数据，
     * 如果和上次一样，会报重复的错。
     * 房态房价房量可以单独推送，并且不要重复推送相同的值
     */
    @ApiOperation(value ="直连推送报价等数据接口",notes = "必须经过auth授权")
    @PostMapping("/BatchPushRoomData")
    public Result<Map<String,String>> batchPushRoomData(@RequestBody BatchPushRoomVo batchPushRoomVo){
        return switchRoomPriceService.batchPushRoomData(batchPushRoomVo);
    }

    /**
     * 获取房价接口
     */
    @ApiOperation(value = "获取房价接口",notes = "必须经过auth授权")
    @PostMapping("/GetRoomPriceDirect")
    public Result<GetRoonPriceReturnVo> getRoomPriceDirect(@RequestBody GetRoomPriceVo getRoomPriceVo){
       return switchRoomPriceService.getRoomPriceDirect(getRoomPriceVo);
    }

    /**
     * 获取房态接口
     * 请求参数与房价差一个字段 直接复用
     */
    @ApiOperation(value = "获取房态接口",notes = "必须经过auth授权")
    @PostMapping("/GetRoomStatusDirect")
    public Result<Object> getRoomStatusDirect(@RequestBody GetRoomPriceVo getRoomPriceVo){
        return switchRoomPriceService.getRoomStatusDirect(getRoomPriceVo);
    }

    /**
     * 获取房量接口
     */
    @ApiOperation(value = "获取房态接口",notes = "必须经过auth授权")
    @PostMapping("/GetRoomInventoryDirect")
    public Result<Object> getRoomInventoryDirect(@RequestBody GetRoomPriceVo getRoomPriceVo){
        return switchRoomPriceService.getRoomInventoryDirect(getRoomPriceVo);
    }

    /**
     * 获取动态售卖规则接口
     */
    @ApiOperation(value = "获取动态售卖规则接口",notes = "必须经过auth授权")
    @PostMapping("/GetSaleRuleDirect")
    public Result<Object> getSaleRuleDirect(@RequestBody GetRoomPriceVo getRoomPriceVo){
        return switchRoomPriceService.getSaleRuleDirect(getRoomPriceVo);
    }

    /**
     * 获取房价房态房量变化接口
     */
    @ApiOperation(value = "获取房价房态房量变化接口",notes = "必须经过auth授权")
    @PostMapping("/GetRoomRateChange")
    public Result<Object> getRoomRateChange(@RequestBody GetRoomRateChangeVo getRoomRateChangeVo){
        return switchRoomPriceService.getRoomRateChange(getRoomRateChangeVo);
    }

    /**
     * 获取推送数据错误日志接口
     */
    @ApiOperation(value = "获取房价房态房量变化接口",notes = "必须经过auth授权")
    @PostMapping("/GetPushRoomDataLog")
    public Result<Object> getPushRoomDataLog(@RequestBody GetPushRoomDataLogVo getPushRoomDataLogVo){
        return switchRoomPriceService.getPushRoomDataLog(getPushRoomDataLogVo);
    }
}
